<template>
  <div class="app-container">
    <el-form :model="queryParams"
      ref="queryForm"
      size="small"
      :inline="true"
      class="form-search"
      label-width="80px">

      <el-form-item label="客户名称"
        prop="customerName">
        <el-input v-model="queryParams.customerName"
          placeholder="请输入客户名称"
          clearable
          style="width: 240px"
          maxlength="50"
          @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label="电话"
        prop="phone">
        <el-input v-model="queryParams.phone"
          placeholder="请输入电话"
          clearable
          style="width: 240px"
          maxlength="50"
          @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label="性别"
        prop="sex">
        <el-select v-model="queryParams.sex"
          placeholder="请选择性别"
          clearable
          style="width: 240px">
          <el-option key="1"
            label="男"
            value="男" />
          <el-option key="0"
            label="女"
            value="女" />
        </el-select>
      </el-form-item>
      <el-form-item label="操作系统"
        prop="os">
        <el-input v-model="queryParams.os"
          placeholder="请输入操作系统"
          clearable
          style="width: 240px"
          maxlength="50"
          @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label="平台"
        prop="paltform">
        <el-input v-model="queryParams.paltform"
          placeholder="请输入平台"
          clearable
          style="width: 240px"
          maxlength="50"
          @keyup.enter.native="handleQuery" />
      </el-form-item>

      <el-form-item>
        <el-button type="primary"
          icon="el-icon-search"
          size="mini"
          @click="handleQuery">搜 索</el-button>
        <el-button icon="el-icon-refresh"
          size="mini"
          @click="resetQuery">重 置</el-button>
      </el-form-item>
    </el-form>
    <div class="section-box">

      <el-table v-loading="loading"
        :data="dataList">
        <el-table-column label="会员名称"
          align="center"
          prop="customerName"
          :show-overflow-tooltip="true"
          min-width="160" />
        <el-table-column label="头像"
          align="center"
          prop="headImage"
          :show-overflow-tooltip="true"
          min-width="120">
          <template slot-scope="scope">
            <div>
              <el-image style="width: 50px; height: 50px;"
                :src="scope.row.headImage"
                :preview-src-list="[scope.row.headImage]"
                fit="cover"
                preview-teleported="true" />
            </div>
          </template>
        </el-table-column>
        <el-table-column label="详细地址"
          align="center"
          prop="addressDetail"
          :show-overflow-tooltip="true"
          min-width="160" />
        <el-table-column label="操作系统"
          align="center"
          prop="os"
          :show-overflow-tooltip="true"
          min-width="120" />
        <el-table-column label="平台"
          align="center"
          prop="platform"
          :show-overflow-tooltip="true"
          min-width="160" />
        <el-table-column label="性别"
          align="center"
          prop="sex"
          min-width="120">
          <template slot-scope="scope">
            <dict-tag :options="dict.type.sys_user_sex"
              :value="scope.row.sex" />
          </template>
        </el-table-column>
        <el-table-column label="国籍"
          align="center"
          prop="nation"
          :show-overflow-tooltip="true"
          min-width="160" />
        <el-table-column label="省份"
          align="center"
          prop="province"
          :show-overflow-tooltip="true"
          min-width="160" />
        <el-table-column label="城市"
          align="center"
          prop="city"
          :show-overflow-tooltip="true"
          min-width="160" />
        <el-table-column label="区域"
          align="center"
          prop="area"
          :show-overflow-tooltip="true"
          min-width="160" />
        <el-table-column label="电话"
          align="center"
          prop="phone"
          :show-overflow-tooltip="true"
          min-width="160" />
        <el-table-column label="状态"
          align="center"
          prop="status"
          :show-overflow-tooltip="true"
          min-width="120">
          <template slot-scope="scope">
            <span>{{scope.row.status == '1'? '有效': '无效'}}</span>
          </template>
        </el-table-column>
        <el-table-column label="生日"
          align="center"
          prop="birthday"
          :show-overflow-tooltip="true"
          min-width="160" />
        <el-table-column label="注册日期"
          align="center"
          prop="createTime"
          :show-overflow-tooltip="true"
          min-width="160" />
      </el-table>

      <pagination v-show="total > 0"
        :total="total"
        :page.sync="queryParams.pageNum"
        :limit.sync="queryParams.pageSize"
        @pagination="getList" />
    </div>

  </div>
</template>

<script>
import {
  getMemberList,
} from "@/api/member/member.js";
import { onInput } from '@/utils/util.js'

export default {
  name: "MemberList",
  dicts: ['sys_user_sex'],
  data () {
    return {
      // 遮罩层
      loading: true,
      // 总条数
      total: 0,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        customerName: null,
        phone: null,
        sex: null,
        os: null,
        paltform: null
      },
      // 数据列表
      dataList: [],
      // 表单参数
      form: {},
      // 表单校验
      rules: {}
    };
  },
  created () {
    this.getList();
  },
  methods: {
    onInput,
    /** 查询列表 */
    getList () {
      this.loading = true;
      getMemberList(this.queryParams).then(
        (response) => {
          this.dataList = response.rows;
          this.total = response.total;
          this.loading = false;
        }
      );
    },
    /** 搜索按钮操作 */
    handleQuery () {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery () {
      this.resetForm("queryForm");
      this.handleQuery();
    },

  },
};
</script>
